﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace AutoLoadDLL.Common
{
    public class RelayCommand : ICommand
    {
        public event EventHandler CanExecuteChanged;
        public Action<object> _action;
        public Func<object, bool> _func;
        public RelayCommand(Action<object> action, Func<object, bool> func)
        {
            _action = action;
            _func = func;
        }

        public bool CanExecute(object parameter)
        {
           return _func?.Invoke(parameter) == true;    
        }

        public void Execute(object parameter)
        {
            _action?.Invoke(parameter); 
        }
    }
}
